#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() 
{
    int i, j;
    int n;
    while (scanf("%d", &n) != EOF) 
    { 
        for (i = 1; i <= n; i++)
        {
            for (j = 1; j <= n; j++)
            {
                if (i == 1 || i == n)
                {
                    printf("* ");
                }
                else
                {
                    if (j == 1 || j == n)
                    {
                        printf("* ");
                    }
                    else
                    {
                        printf("  ");
                    }
                }
            }
            printf("\n");
        }
    }
    return 0;
}